<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        body {
            background-color: #f1f1f1;
            padding: 10px;
        }
        
        .box {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
        }
        
        p {
            text-align: center;
            width: 100%;
        }
        
        input {
            width: 80%;
            margin: 0 auto;
            border: none;
            height: 30px;
            border: 1px solid #ccc;
            outline: none;
            margin-top: 1.5rem;
            padding-left: 10px;
        }
        
        .button {
            display: flex;
            width: 81%;
            justify-content: space-evenly;
            margin-top: 2rem;
        }
        
        .title {
            width: 80%;
            font-size: 16px;
            color: red;
            height: 20px;
        }
        
        button {
            width: 30%;
            border: none;
            border: 1px solid #ccc;
            height: 30px;
            background-color: #3B97FD;
            color: #fff;
        }
    </style>
</head>

<body>
    <div class="box">
        <p>注册账号</p>
        <div class="title">
            <span></span>
        </div>
        <input type="text" id="username" name="username" placeholder="请输入8-16位账号" required="required">
        <input type="password" id="password" name="password" placeholder="请输入6-18位密码">
        <div class="button">
            <button onclick="getGo()">返回登录</button>
            <button class="login">点击注册</button>
        </div>

    </div>
    <script src="/js/jquery-3.6.0.min.js"></script>
    <script src="/js/config.js"></script>
    <script>
        $('.login').click(function() {
            var settings = {
                "url": "http://58.210.112.60:38102/Wechat/Api/Register",
                "method": "POST",
                "timeout": 0,
                "headers": {
                    "Content-Type": "application/json",
                    "Accept": "*/*",
                },
                "data": JSON.stringify({
                    "username": $('#username').val(),
                    "password": $('#password').val()
                }),
            };
            if ($('#username').val().length == 0) {
                $('.title').html('账号不能为空')
            } else if ($('#username').val().length < 8 || $('#username').val().length > 16) {
                $('.title').html('请输入8-16位账号')
            } else {
                $('.title').html('')
            }
            if ($('#password').val().length == 0) {
                $('.title').html('密码不能为空')
            } else if ($('#password').val().length < 6 || $('#password').val().length > 18) {
                $('.title').html('请输入6-18位密码')
            }
            if ($('#username').val().length >= 8 && $('#username').val().length <= 16 && $('#password').val().length >= 6 || $('#password').val().length <= 18) {
                $.ajax(settings).done(function(response) {
                    // window.location.href = 'long'
                });
            }
        })


        function getGo() {
            window.history.go(-1)
        }
    </script>
</body>

</html>